import Mock from "mockjs";

const ApiPath = {
  list: "/purchaseOrder/page",
  detail: "/purchaseOrder/"
}

const purchaseList = Mock.mock("/purchaseOrder/page","post",(options)=>{
  const { page=1, size=10 } = JSON.parse(options.body)
  const info = {
    success: true,
    code: 200,
    message: '操作成功',
    data: {
      // 属性 list 的值是一个数组，其中含有 1 到 5 个元素
      'content|10': [{
          // 属性 sid 是一个自增数，起始值为 1，每次增 1
          'id|+1': 1,
          // 属性 userId 是一个5位的随机码
          'purchaseNo|5': '',
          'applicantCode|5': '',
          'applicant|5': '',
          createTime: new Date().getTime(),
          'quantity|+1': 1,
      }],
      number: page,
      numberOfElements: 10,
      size: size,
      totalElements: 114,
      totalPages: 12,
    }
  }
  console.log(Mock.mock(info))
  return Mock.mock(info)
})

const purchaseDetail = Mock.mock(RegExp(ApiPath.detail + ".*"), "get", {})

export const purchaseMock = {
  purchaseList,
}